

import 'package:basic_common/app_theme.dart';
import 'package:basic_common/common_exports.dart';
import 'package:basic_widgets/app_bar_widget.dart';
import 'package:flutter/gestures.dart';

import 'patient_health_controller.dart';
import 'view/basic_info.dart';
import 'view/health_info.dart';

class PatientHealthPage extends GetView<PatientHealthController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: backAppbar(title: "健康管理"),
      body: Container(
        padding: EdgeInsets.symmetric(horizontal: ScreenHelper.width(15)),
        height: ScreenHelper.screenHeight,
        child: Column(
          children: [
            _buildTitle(),
            Expanded(
              child: TabBarView(
                  controller: controller.tabController,
                  children: [BasicInfoWidget(), HealthInfoWidget()]),
            ),
          ],
        ),
      ),
    );
  }

  ///  tabBar Title
  Widget _buildTitle() {
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Expanded(
          child: SizedBox(
            height: 48,
            child: TabBar(
                controller: controller.tabController,
                indicatorSize: TabBarIndicatorSize.label,
                labelPadding: EdgeInsets.zero,
                padding: EdgeInsets.zero,
                indicatorWeight: 1,
                dragStartBehavior: DragStartBehavior.down,
                indicatorColor: AppTheme.primyColor,
                labelColor: AppTheme.dartTextColor,
                labelStyle: TextStyle(
                    color: AppTheme.dartTextColor,
                    fontSize: ScreenHelper.sp(16)),
                unselectedLabelColor: AppTheme.weakTextColor,
                tabs: controller.todoTitleList
                    .map<Widget>((item) => buildTitleListWidget(title: item))
                    .toList()),
          ),
        ),
      ],
    );
  }

  /// 待办事项标题Item
  buildTitleListWidget({required String title}) {
    return Align(
      alignment: Alignment.center,
      child: Tab(
        text: title,
      ),
    );
  }
}
